import { createPinia, defineStore } from "pinia";
import persistedstateDefault from "pinia-plugin-persistedstate";
// ----------------------------------------------------------------------------
export const StoreID = {
    TEST_STORE: "APP_TEST_STORE",
};

export const pinia = createPinia();
pinia.use(persistedstateDefault);

export interface TestState {
    /**
     * 令牌
     */
    token: string;
}

export const useTestStore = defineStore(StoreID.TEST_STORE, {
    state: (): TestState => ({
        token: "",
    }),

    actions: {
        /**
         * 设置令牌
         */
        setToken(token: string) {
            this.token = token;
        },
    },

    persist: true,
});

export const defaultStorage: Storage = localStorage;
